﻿@{
    ViewBag.Title = "玉溪水利";
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <title>玉溪水利</title>
    <meta name="apple-mobile-web-app-title" content="AMUI Touch">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="~/skin/mobile/css/c01.css" rel="stylesheet" />
</head>
<body>

    <script src="http://g.alicdn.com/dingding/open-develop/1.5.1/dingtalk.js" type="text/javascript"></script>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <div id="loading" style="display: block;">
        <div class="loaderAni">
            <div class="pacman">
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </div>
            <div class="loaderAni-text">努力加载中...</div>
        </div>
    </div>
    <div style=" display:none;">
        @if (ViewBag.bakurl == null)
        {
            <input type="text" id="gourl" name="gourl" value="/mobile/RiverSource/index" />
        }
        else
        {
           
                <input type="text" id="gourl" name="gourl" value="@ViewBag.bakurl" />
        }
        @Html.Hidden("agentid")
    </div>
    <script>
        //alert($("#agentid").val());
        $.post("/mobile/login/init", "url=@ViewBag.url&CorpID=ss&agentid=" + $("#agentid").val(), function (_config) { 
            //alert(_config.agentId);
            dd.config({
                agentId: _config.agentId,
                corpId: _config.corpId,
                timeStamp: _config.timeStamp,
                nonceStr: _config.nonceStr,
                signature: _config.signature,
                jsApiList: ['runtime.info', 'device.notification.prompt', 'biz.chat.pickConversation', 'device.notification.confirm',
           'device.notification.alert',
           'device.notification.prompt',
           'biz.chat.open',
           'biz.util.open',
           'biz.user.get','device.geolocation.get',
           'biz.contact.choose',
           'biz.telephone.call',
           'biz.ding.post']
            });

            //dd.ui.pullToRefresh.disable();
            dd.ready(function () {
                dd.ui.pullToRefresh.disable();
                dd.biz.navigation.setTitle({
                    title: '河长信息平台',
                    onSuccess: function (data) {
                    },
                    onFail: function (err) {
                        log.e(JSON.stringify(err));
                    }
                });
                //	 alert('dd.ready rocks!');

                dd.runtime.info({
                    onSuccess: function (info) {
                        console.log('runtime info: ' + JSON.stringify(info));
                    },
                    onFail: function (err) {
                        console.log('fail: ' + JSON.stringify(err));
                    }
                });
                dd.ui.pullToRefresh.enable({
                    onSuccess: function () {
                    },
                    onFail: function () {
                    }
                })
                dd.runtime.permission.requestAuthCode({
                    corpId: _config.corpId,
                    onSuccess: function (info) {
                       // window.location.href = $("#gourl").val();
                        //return false;
                        var _url = 'userinfo?code=' + info.code + '&corpid=' + _config.corpId
                        $.ajax({
                            url: _url,
                            type: 'get',
                            success: function (data, status, xhr) {
                                if (data == "true") {
                                    window.location.href = $("#gourl").val();

                                }
                                else {
                                    alert(data);
                                }

                            },
                            error: function (xhr, errorType, error) {
                                logger.e('');
                                alert(errorType + ', ' + error);
                            }
                        });


                    },
                    onFail: function (err) {
                        alert('fail: ' + JSON.stringify(err));
                    }
                });
            });

            dd.error(function (err) {
                alert('dd error: ' + JSON.stringify(err));
            });

        })
    </script>
</body>
</html>
